package com.ler.yrmall.cart.rpc;

import com.ler.yrmall.cart.api.CartApi;
import com.ler.yrmall.cart.dto.CartDTO;
import com.ler.yrmall.cart.service.CartService;
import com.ler.yrmall.basic.Result;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Leron
 */
@Service
@DubboService
public class CartApiImpl implements CartApi {

    @Resource
    private CartService cartService;

    @Override
    public Result<CartDTO> getCart() {
        CartDTO cartList = cartService.getCartList();
        return Result.ok(cartList);
    }

    @Override
    public void delete(List<Long> skuIds) {
        skuIds.forEach(item -> cartService.deleteCartItem(item));
    }

}
